package com.dailycodebuffer.springbootmongodb.controller;

import com.dailycodebuffer.springbootmongodb.collection.Category;
import com.dailycodebuffer.springbootmongodb.service.CategoryService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;


/**
 * 控制层
 *
 * @author makejava
 * @since 2025-01-04 00:23:29
 */
@RestController
@RequestMapping("/category")
@AllArgsConstructor
public class CategoryController {

	private CategoryService categoryService;

	/**
	 * 获取列表(分页)
	 */
	@GetMapping("/list")
	public Page<Category> list(Pageable page) {
		return null;
	}

	/**
	 * 获取
	 */
	@GetMapping("/level/{value}")
	public Category get(@PathVariable("value") Integer id) {
		return categoryService.findById(id);
	}

	/**
	 * 添加
	 */
	@PostMapping("/add")
	public void add(@RequestBody Category category) {
		categoryService.save(category);
	}


}

